try {
    Type.registerNamespace('GeneralOutMakeUtil');
    
    GeneralOutMakeUtil.commitData=function(billinfos,scanpks,callback){
	    $js.showLoadingBar();	 
	    //测试连接
		var rtn=NCMMDBUtil.testNCConnection(function(data) {
			if(data == false || data == "false") {
				$js.hideLoadingBar();
				$toast("连接服务器失败，无法提交！");
				return false;
			} else {			   
				var tmprtn=NCMMDBUtil.submitLocaldataToNC("4Imake", billinfos, function(commitInfo) {
					$js.hideLoadingBar();
					if(!NCMMPubUtil.isEmpty(commitInfo)) {
						if(commitInfo.return == null || commitInfo.return == "") {
							$alert("提交失败：" + $jsonToString(commitInfo));
							return false;
						} else if(commitInfo["return"].returnFlag == 1) {
							GeneralOutMakeUtil.deleteVOsAfterCommit(scanpks);
							if(callback != null && callback != undefined && typeof(callback) == 'function') {                                 
                                    callback(scanpks);
                                }
                            $toast("提交成功！");								
							return true;						
						} else {
							$alert("提交失败" + $jsonToString(commitInfo.return.returnDesc));
							return false;
						}
					} else {
						$alert("提交失败");
						return false;
					}
				});
				return tmprtn;
			}
		});		
	};
    GeneralOutMakeUtil.deleteVOsAfterCommit = function(scanpks) {
		var sql =" pk_scan in ('0'";
			for(var i = 0; i < scanpks.length; i++) {
				sql = sql + ",'" + scanpks[i] + "'";
			}
			sql = sql + ")";
		NCMMPubUtil.batchDeleteByCondition(GeneralOutMakeVO, sql);
	}
    GeneralOutMakeUtil.openDropDownList = function(controlid) {
		$menu.openDropDownList({
			"controlid": controlid, //目标控件的id
			"dropDownListWidth": "100", //菜单项的宽度
			"background": "#f2f2f2",
			//"background-image":"app.png",
			"color": "#ee4311",
			"font-size": "12",
			"halign": "center", //right  center
			"split-color": "#ee4311",
			//"margin-left":"10",
			"panelstyle": "round-div",
			"border-color": "#ee4311",
			//"showtype":"right",
			"dropItemsArray": [{
				"id": "id_homepage",
				"name": "主菜单", //菜单项名称
				"action": "gotohomepage()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_datamanage",
				"name": "数据管理", //菜单项名称
				"action": "gotodatamanage()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_setting",
				"name": "业务设置", //菜单项名称
				"action": "setting()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_logout",
				"name": "注销", //菜单项名称
				"action": "logout()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_scanlist",
				"name": "扫描记录", //菜单项名称
				"action": "gotoscanlist()" //点击该菜单项时执行的JS方法
			}]
		});
    }
    
    GeneralOutMakeUtil.openDropDownListForScan = function(controlid) {
		$menu.openDropDownList({
			"controlid": controlid, //目标控件的id
			"dropDownListWidth": "100", //菜单项的宽度
			"background": "#f2f2f2",
			//"background-image":"app.png",
			"color": "#ee4311",
			"font-size": "12",
			"halign": "center", //right  center
			"split-color": "#ee4311",
			//"margin-left":"10",
			"panelstyle": "round-div",
			"border-color": "#ee4311",
			//"showtype":"right",
			"dropItemsArray": [{
				"id": "id_homepage",
				"name": "主菜单", //菜单项名称
				"action": "gotohomepage()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_datamanage",
				"name": "数据管理", //菜单项名称
				"action": "gotodatamanage()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_setting",
				"name": "业务设置", //菜单项名称
				"action": "setting()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_logout",
				"name": "注销", //菜单项名称
				"action": "logout()" //点击该菜单项时执行的JS方法
			}, {
				"id": "id_scanlist",
				"name": "扫描记录", //菜单项名称
				"action": "gotoscanlistForScan()" //点击该菜单项时执行的JS方法
			}]
		});
    }
    
	function gotohomepage() {
		$view.open({
			"viewid": "com.yonyou.ncmm_pac_pda.HomePage", //目标页面（首字母大写）全名
			"isKeep": "true", //打开新页面的同时是否保留当前页面，true为保留，false为不保留
		});
	}
	
	function gotodatamanage() {
		$view.open({
			"viewid": "com.yonyou.ncmm_pac_pda.DM_main", //目标页面（首字母大写）全名
			"isKeep": "true", //打开新页面的同时是否保留当前页面，true为保留，false为不保留
		});
	}
	
	function setting() {
		$view.open({
			"viewid": "com.yonyou.ncmm_pac_pda.BusinessSettingPage", //目标页面（首字母大写）全名
			"isKeep": "true", //打开新页面的同时是否保留当前页面，true为保留，false为不保留
		});
	}
	
	function logout() {
		//$view.close();
		$view.open({
			"viewid": "com.yonyou.ncmm_pac_pda.LoginPage", //目标页面（首字母大写）全名
			"isKeep": "false", //打开新页面的同时是否保留当前页面，true为保留， false为不保留
		});
	}
	
	function gotoscanlist() {
		//$view.close();
		$view.open({
			"viewid": "com.yonyou.ncmm_pac_pda.GeneralOutMakeList", //目标页面（首字母大写）全名
			"isKeep": "true", //打开新页面的同时是否保留当前页面，true为保留， false为不保留
		});
	}
	
	function gotoscanlistForScan() {
		//$view.close();
		$view.open({
			"viewid": "com.yonyou.ncmm_pac_pda.GeneralOutMakeList", //目标页面（首字母大写）全名
			"isKeep": "false", //打开新页面的同时是否保留当前页面，true为保留， false为不保留
		});
	}
	
} catch(e) {
	$e(e);
}